/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fh.view;

import fh.view.running.CurrentTourneyOverview;
import fh.controller.EventController;
import fh.model.Event;
import fh.model.Player;
import fh.view.masterclass.DetailMasterclass;
import fh.view.tourney.DetailTourney;

/**
 *
 * @author Bart
 */
public class EditPaymentStatus extends javax.swing.JFrame {

    Event anEvent;
    Player aPlayer;
    EventController ec;

    /**
     * Creates new form EditPaymentStatus
     */
    public EditPaymentStatus() {
        initComponents();
    }

    public EditPaymentStatus(Player p, Event e) {
        initComponents();
        anEvent = e;
        aPlayer = p;
        ec = new EventController();
        PlayerNameField.setText(aPlayer.getFirstname() + " " + aPlayer.getLastname());
        EventNameField.setText(anEvent.getName());
        PaymentStatusCheckBox.setSelected(ec.getPayedStatus(anEvent.getId(), aPlayer.getId()));

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        PlayerOverviewButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        LocationEventMainButton = new javax.swing.JButton();
        CurrentTourneyButton3 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        PaymentStatusCheckBox = new javax.swing.JCheckBox();
        jLabel3 = new javax.swing.JLabel();
        PlayerNameField = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        EventNameField = new javax.swing.JTextField();
        EditPaymentStatusButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Betaalstatus wijzigen");
        setMaximumSize(new java.awt.Dimension(800, 600));
        setMinimumSize(new java.awt.Dimension(800, 600));
        setResizable(false);

        PlayerOverviewButton.setText("Speler beheer");
        PlayerOverviewButton.setMaximumSize(new java.awt.Dimension(111, 23));
        PlayerOverviewButton.setMinimumSize(new java.awt.Dimension(111, 23));
        PlayerOverviewButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PlayerOverviewButtonActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 30)); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Full House");
        jLabel1.setToolTipText("");

        LocationEventMainButton.setText("Locatie & Event");
        LocationEventMainButton.setMaximumSize(new java.awt.Dimension(111, 23));
        LocationEventMainButton.setMinimumSize(new java.awt.Dimension(111, 23));
        LocationEventMainButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LocationEventMainButtonActionPerformed(evt);
            }
        });

        CurrentTourneyButton3.setText("Toernooi runnen");
        CurrentTourneyButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CurrentTourneyButton3ActionPerformed(evt);
            }
        });

        jLabel2.setText("Heeft speler betaald:");

        PaymentStatusCheckBox.setText("Betaald");

        jLabel3.setText("Speler:");

        PlayerNameField.setEditable(false);

        jLabel4.setText("Event:");

        EventNameField.setEditable(false);

        EditPaymentStatusButton.setText("Opslaan");
        EditPaymentStatusButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EditPaymentStatusButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(38, 38, 38)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(EditPaymentStatusButton)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(layout.createSequentialGroup()
                                            .addComponent(LocationEventMainButton, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGap(18, 18, 18)
                                            .addComponent(PlayerOverviewButton, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGap(18, 18, 18)
                                            .addComponent(CurrentTourneyButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(layout.createSequentialGroup()
                                            .addGap(68, 68, 68)
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addComponent(jLabel4)
                                                .addComponent(jLabel3)))
                                        .addComponent(jLabel2)
                                        .addGroup(layout.createSequentialGroup()
                                            .addGap(148, 148, 148)
                                            .addComponent(PaymentStatusCheckBox))))
                                .addGap(0, 58, Short.MAX_VALUE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(196, 196, 196)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(EventNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(PlayerNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(PlayerOverviewButton, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(CurrentTourneyButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(LocationEventMainButton, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(43, 43, 43)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(PlayerNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(EventNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(PaymentStatusCheckBox))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 192, Short.MAX_VALUE)
                .addComponent(EditPaymentStatusButton)
                .addGap(99, 99, 99))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void PlayerOverviewButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PlayerOverviewButtonActionPerformed
        new PlayerOverview().setVisible(true);
        this.dispose();
    }//GEN-LAST:event_PlayerOverviewButtonActionPerformed

    private void LocationEventMainButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LocationEventMainButtonActionPerformed
        new LocationEventOverview().setVisible(true);
        this.dispose();
    }//GEN-LAST:event_LocationEventMainButtonActionPerformed

    private void CurrentTourneyButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CurrentTourneyButton3ActionPerformed
        new CurrentTourneyOverview().setVisible(true);
        this.dispose();
    }//GEN-LAST:event_CurrentTourneyButton3ActionPerformed

    private void EditPaymentStatusButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EditPaymentStatusButtonActionPerformed
        ec.updatePayedStatus(anEvent.getId(), aPlayer.getId(), PaymentStatusCheckBox.isSelected());

        if (anEvent.getType() == "Toernooi") {
            new DetailTourney(anEvent).setVisible(true);
            this.dispose();
        } else {
            new DetailMasterclass(anEvent).setVisible(true);
            this.dispose();
        }

    }//GEN-LAST:event_EditPaymentStatusButtonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(EditPaymentStatus.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(EditPaymentStatus.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(EditPaymentStatus.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(EditPaymentStatus.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new EditPaymentStatus().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton CurrentTourneyButton3;
    private javax.swing.JButton EditPaymentStatusButton;
    private javax.swing.JTextField EventNameField;
    private javax.swing.JButton LocationEventMainButton;
    private javax.swing.JCheckBox PaymentStatusCheckBox;
    private javax.swing.JTextField PlayerNameField;
    private javax.swing.JButton PlayerOverviewButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    // End of variables declaration//GEN-END:variables
}
